﻿using Core.Aspects;
using Core.Messages;
using Library.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{    
    public abstract class BaseService
    {       
        public BaseService()
        {                   
        }

        [HandleServiceError]
        protected Response Run(Action action)
        {
            Response response = new Response();
            action();
            response.Success = true;
            return response;
        }

        [HandleServiceError]
        protected Response<T> Run<T>(Func<T> func)
        {
            Response<T> response = new Response<T>();
            response.Value = func();
            response.Success = true;
            return response;
        }
    }
}
